﻿using System;
using System.Web.UI;

namespace ETestIT.UI.AppControls
{
    using Domain.Entities;

    public partial class JobTitleAddEdit : UserControl
    {
        public event EventHandler Update;

        public string JobTitleName
        {
            get { return tbJobTitle.Text.Trim(); }
            set { tbJobTitle.Text = value; }
        }

        public void SetModel(JobTitle jobTitle)
        {
            JobTitleName = jobTitle.Name;      
        }

        public void UpdateModelFromUserInput(JobTitle jobTitle)
        {
            jobTitle.Name = JobTitleName;
            
        }

        public bool IsInputValide()
        {
            return !string.IsNullOrEmpty(JobTitleName);
        }

        protected void bntUpdate_Clicked(object sender, EventArgs e)
        {
            if (Update != null)
                Update(sender, e);
        }
    }
}